<%--
  Created by IntelliJ IDEA.
  User: user
  Date: 2021/7/20
  Time: 19:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>邮箱验证码</title>
</head>
<style>
    @import "/css/daohang.css";
    @import "/css/header.css";
</style>
<div class="header_bd">
    <!-- 头部 -->

    <div class="header" >
        <h1><img style="height: 50px;width: 180px"
                 src="">
        </h1>
        <form>
            <input type="text" name="search" placeholder="Search.." class="search">
        </form>
        <button class="searchButton searchButton2">立即搜索</button>
        <div class="login">
        </div>
    </div>
    <div>
        <div class="topNav">
            <!-- 导航栏 -->
            <div style="float: left;">
                <button style="" class="links_button button dropdown">
                    <a href="tuijian.jsp" style="text-decoration: none">推荐</a>
                    <span class="dropdown-content">
                    <a href="#">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                </span>
                </button>
                <button style="" class="links_button button dropdown">
                    <a href="yingshi.jsp" style="text-decoration: none">影视</a>
                    <span class="dropdown-content">
                    <a href="#">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                </span>
                </button>
                <button style="" class="links_button button dropdown">
                    <a href="yinyue.jsp" style="text-decoration: none">音乐</a>
                    <span class="dropdown-content">
                    <a href="#">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                </span>
                </button>
                <button style="" class="links_button button dropdown">
                    <a href="youxi.jsp" style="text-decoration: none">游戏</a>
                    <span class="dropdown-content">
                    <a href="#">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                </span>
                </button>
                <button style="" class="links_button button dropdown">
                    <a href="tiyu.jsp" style="text-decoration: none">体育</a>
                    <span class="dropdown-content">
                    <a href="#">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                </span>
                </button>
                <button style="" class="links_button button dropdown">
                    <a href="zongyi.jsp" style="text-decoration: none">综艺</a>
                    <span class="dropdown-content">
                    <a href="#">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                </span>
                </button>
                <button style="" class="links_button button dropdown">
                    <a href="yule.jsp" style="text-decoration: none">娱乐</a>
                    <span class="dropdown-content">
                    <a href="#">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                </span>
                </button>
                <button style="" class="links_button button dropdown">
                    <a href="dongman.jsp" style="text-decoration: none">动漫</a>
                    <span class="dropdown-content">
                    <a href="#">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                </span>
                </button>
                <button style="" class="links_button button dropdown">
                    <a href="shenghuo.jsp" style="text-decoration: none">生活</a>
                    <span class="dropdown-content">
                    <a href="#">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                </span>
                </button>
                <button style="" class="links_button button dropdown">
                    <a href="meishi.jsp" style="text-decoration: none">美食</a>
                    <span class="dropdown-content">
                    <a href="#">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                </span>
                </button>
                <button style="" class="links_button button dropdown">
                    <a href="chongwu.jsp" style="text-decoration: none">宠物</a>
                    <span class="dropdown-content">
                    <a href="#">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                </span>
                </button>
            </div>
        </div>
    </div>
</div>
    <script src="/js/jquery/jquery-3.3.1.js"></script>
    <script>
        function checkEmails() {
            var email = $('#emails_text').val();
            if (email == '') {
                alert('请输入邮箱');
                return;
            }
            var reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
            if (!reg.test(email)) {
                alert('邮箱格式错误');
                return;
            }
            $.ajax({
                url:'/user/update_password_code',
                type:'post',
                data:{email:email},
                dataType:'json',
                success:function (data){
                    if(1==data){
                        alert('已发送邮件至您的邮箱');
                    }else if(0==data){
                        alert('该邮箱尚未注册');
                    }else{
                        alert('未知的状态')
                    }
                },
                error:function (){
                    alert('运行异常');
                }
            });
        }
        function findPwd(){
            var email = $('#emails_text').val();
            if (email == '') {
                alert('请输入邮箱');
                return;
            }
            var reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
            if (!reg.test(email)) {
                alert('邮箱格式错误');
                return;
            }
            var  codes=$('#code_text').val();
            if(''==codes)
            {
                alert('请填写邮箱验证码');
                return;
            }
            if(!/^\d{6}$/.test(codes))
            {
                alert('邮箱验证码格式错误');
                return;
            }
            $('form').submit();
        }
    </script>
<body>
<div style="width:100%;height:100%">
<form action="/user/check_codes" method="post">
    <div style="background-image: linear-gradient(to bottom right, white, aqua); border-radius: 25px;height:250px;width:300px;position: fixed;left: 600px;top:200px">
    <ul style="list-style: none;line-height: 28px">
        <li><h3 style="text-align:center;border-radius: 15px;letter-spacing:15px">找回密码</h3></li>
        <li><span>邮箱:</span><input  style="border-radius: 15px;" id="emails_text" type="email" name="email" placeholder="请输入邮箱" required><button type="button" onclick="checkEmails()">发送验证码</button></li>
        <li><span>验证码:</span><input  style="border-radius: 15px;" id="code_text" type="text" name="codes" placeholder="请输入邮箱验证码" required></li>
        <li><button type="button" onclick="findPwd()">找回密码</button></li>
    </ul>
    </div>
</form>
</div>
</body>
</html>
